package jannex.query;

import jannex.sql.JxPreparedStatement;

public abstract class Clause<E> extends Expression {

    protected Binding<E> binding;

    protected Clause(Binding<E> binding) {
        this.binding = binding;
        binding.register(this);
    }

    protected Clause() {
    }

    public void execute() {
        throw new UnsupportedOperationException();
    }

    public JxPreparedStatement preparedStatement() {
        throw new UnsupportedOperationException();
    }

    public JxPreparedStatement prepare() {
        throw new UnsupportedOperationException();
    }

    @SuppressWarnings("unchecked")
    public <S extends PlannedStatement> S clause(Clause<E> clause) {
        return (S) binding.getStatement().clause(clause);
    }

    @SuppressWarnings("unchecked")
    public <S extends PlannedStatement> S statement() {
        return (S) binding.getStatement();
    }

    public AppendClause<E> append() {
        return null;
    }

    public Clause<E> and() {
        return this;
    }

    Binding<E> binding() {
        return binding;
    }

}
